home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1988-04-07 | 1.4 KB | 43 lines | [TEXT/ttxt] |
- ;; Larry Mulcahy 1988
- ;; file I/O
-
- (provide 'file-io)
- (require 'iteration "iter")
- (require 'string)
- (require 'character "char")
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; get-word
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun get-word (&optional (stream *standard-input*)
- &key (character-predicate #'graphic-char-p))
- (let ((acc nil))
- (skip-bad-characters stream :character-predicate character-predicate)
- (while (let ((c (peek-char nil stream)))
- (and c (funcall character-predicate c)))
- (push (read-char stream) acc))
- (list-of-characters-to-string (reverse acc))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; skip-bad-characters
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun skip-bad-characters (&optional (stream *standard-input*)
- &key (character-predicate #'graphic-char-p))
- (while (let ((c (peek-char nil stream)))
- (and c (not (funcall character-predicate c))))
- (read-char stream)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; unique-filename
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun unique-filename ()
- (let* ((s (number-to-string (time)))
- (big (length s)))
- (concatenate 'string
- (subseq s 0 (- big 3))
- "."
- (subseq s (- big 3)))))
-